package com.techysky.repository;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.jpa.repository.Query;

import com.techysky.entity.UserAnswerRecord;

public interface UserAnswerRecordRepository  extends CoreRepository<UserAnswerRecord, Serializable> {
	
	List<UserAnswerRecord> findByPaperIdAndCreateUserOrderByOrderCodeAsc(String paperId, String createUser1);
	@Query(value="SELECT  t1.order_code   FROM  sys_question_paper t1  WHERE  t1.paper_id =?1 and t1.question_id=?2",nativeQuery=true)
	Long findOrderCodeByPaperIdAndQuestionId(String paperId,String questionId);
	@Query(value="SELECT  ua.user_answer   FROM  sys_user_answer_record ua  WHERE  ua.paper_id =?1 and ua.code=?2 and ua.order_code=?3 and ua.create_user=?4",nativeQuery=true)
	String findUserAnswer(String paperId, String code1, Long orderCode1,
			String string);
	@Query(value="SELECT  *   FROM  sys_user_answer_record ua  WHERE  ua.paper_id =?1 and ua.code=?2 and ua.order_code=?3 and ua.create_user=?4",nativeQuery=true)
	List<UserAnswerRecord> findAllua(String paperId, String code, Long orderCode2, String string);
	
	List<UserAnswerRecord> findScoreByPaperIdAndCreateUser(String paperId, String string);


	List<UserAnswerRecord> findByPaperIdAndCreateUserAndCodeOrderByOrderCodeAsc(String paperId, String createUser1,
			String code);
	@Query(value="SELECT  *   FROM  sys_user_answer_record ua  WHERE  ua.paper_id =?1 and ua.create_user=?2",nativeQuery=true)
	List<UserAnswerRecord> findAlluas(String paperId, String string);
	
	
	UserAnswerRecord findByPaperIdAndQuestionIdAndCreateUser(String id, String key, String id2);
	

}
